class Area < ActiveRecord::Base
  acts_as_nested_set
  
  has_many :schools, :dependent => :destroy
  
  def self.conditions_by_like(value, *columns)
    columns = self.column_names if columns.size == 0
    columns = columns[0] if columns[0].kind_of?(Array)
    conditions = columns.map { |c|
      c = c.name if c.kind_of? ActiveRecord::ConnectionAdapters::Column
      "areas.#{c} LIKE " + ActiveRecord::Base.connection.quote("%#{value}%")
    }.join(" OR ")
  end
  
end
